/*-----------------------------------------------------------------------------------
 *
 * 프로그램명	: HomePageDAO.java
 * Version		: 1.0
 * 작성일 		: 2006-08-16
 * 작성자		:
 * 수정일 		:
 * 수정자		:
 * 설명		 	:
 * 기능		 	:
 *
 * Copyright (c) 2000 by H&H  All Rights Reserved.
 *
-------------------------------------------------------------------------------------*/
package com.qbooks.member;
 
import java.io.*;

import java.util.*;
import java.sql.*;

import com.zll.framework.db.DBManager;
import com.zll.framework.model.HashBox;
import com.zll.framework.model.HashList;



public class MemberDAO
{
	
	public HashList selectMemberInfo(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/member.xml", "select_member_info", infos);
	}
	public HashList selectMemberList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/member.xml", "select_member_list", infos);
	}

	public HashList selectMemberDeviceList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/member.xml", "select_member_mac_list", infos);
	}
	
	public HashList selectMemberSalesList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/member.xml", "select_member_sales_list", infos);
	}
	
	public void saveMember(HashMap infos) throws Exception
	{
		Connection conn = null;

        try
		{
			conn = DBManager.getConnection();

			if ("C".equals(infos.get("job_type"))) {
				DBManager.executeUpdate("/member.xml", "insert_member", infos, conn);
			} else if ("U".equals(infos.get("job_type"))) {
				DBManager.executeUpdate("/member.xml", "update_member", infos, conn);
			} else if ("O".equals(infos.get("job_type"))) {
				DBManager.executeUpdate("/member.xml", "out_member", infos, conn);
			}
			
			conn.commit();
	    }
	    catch(Exception e)
	    {
	    	DBManager.rollback(conn);
	    	throw e;
		}
	    finally
	    {
	    	DBManager.closeConnection(conn);
		}
	}
	
	public void updateLastLogin(HashMap infos) throws Exception 
	{
		Connection conn = null;

        try
		{
			conn = DBManager.getConnection();

			DBManager.executeUpdate("/member.xml", "update_member_last_login", infos, conn);
			
			
			conn.commit();
	    }
	    catch(Exception e)
	    {
	    	DBManager.rollback(conn);
	    	throw e;
		}
	    finally
	    {
	    	DBManager.closeConnection(conn);
		}
	}
	
}
